  function EscapeSensitiveSplitOld(sString)
  {
    var aRet = new Array();
    var iNumberOfElements=0;
    var sNewString = "";
    
    while(sString.length) {
      switch(sString.charAt(0)) {
        case '\\':
          sNewString += sString.charAt(1);
          sString = sString.substr(2);
          break;
        case ',':
          aRet[iNumberOfElements++] = sNewString;
          sString =  sString.substr(1);           
          sNewString = "";
          break;
        default:
          sNewString += sString.charAt(0);
          sString = sString.substr(1);           
      }
    }
    
    //Ran out of characters, may have completed a new string
    if(sNewString.length) {
      aRet[iNumberOfElements++] = sNewString;
    }

    return aRet; 
  }
  
  function EscapeSensitiveSplit(sString)
  {
    var aRet = new Array();
    var iNumberOfElements=0;
    var sNewString = "";
    var iReadIndex = 0;
    
    while(sString.length > iReadIndex) {
      switch(sString.charAt(iReadIndex)) {
        case '\\':
          sNewString += sString.charAt(iReadIndex+1);
          iReadIndex+=2
          break;
        case ',':
          aRet[iNumberOfElements++] = sNewString;
          iReadIndex += 1;
          sNewString = "";
          break;
        default:
          sNewString += sString.charAt(iReadIndex);
          iReadIndex += 1;
      }
    }
    
    //Ran out of characters, may have completed a new string
    aRet[iNumberOfElements++] = sNewString;

    return aRet; 
  }
  
  function EPG_DeSerialise(sData)
  {
    var i;
    var aProgrammes = sData.split(/\},\{/);
    var aRetProgrammes;
        
    for(i=0; i < aProgrammes.length; i++) {
      //Remove the preceeding or trailing "{" and "}" characters
      if(0 == i) {
        //Remove the first {
        aProgrammes[i] = aProgrammes[i].substr(1);
      }
      
      if(aProgrammes.length-1 == i) {
        //last one -- remove tailing }
        aProgrammes[i] = aProgrammes[i].substr(0, aProgrammes[i].length-1);
      }      
    } 
   
    var aRetProgrammes = new Array();
    for(i=0; i < aProgrammes.length; i++) {      
      aRetProgrammes[i]= new Array();
      
      aSplit = EscapeSensitiveSplit(aProgrammes[i]);
      
      aRetProgrammes[i]["iChannelID"]     = aSplit[0];
      aRetProgrammes[i]["iProgrammeID"]   = aSplit[1];
      aRetProgrammes[i]["tStartTime"]     = parseInt(aSplit[2]);
      aRetProgrammes[i]["iDuration"]      = parseInt(aSplit[3]);
      aRetProgrammes[i]["sProgrammeName"] = aSplit[4];
      aRetProgrammes[i]["sSummary"]       = aSplit[5];
      aRetProgrammes[i]["sDescription"]   = aSplit[6];            
    }
        
    return aRetProgrammes;
  }

